<?php
class getpass extends CI_Controller {
	function __construct() {
		parent::__construct ();
		define("CACHE_PATH","./application/cache");  //设置缓存文件放的地址
		$this->load->helper ( 'url' );
		$this->load->helper ( 'cache' );
		$this->load->library ( 'cache' );
		// 加载验证码类
		session_start();
		$this->load->library ( 'authcode' );
	}
	public function index() {
		$lang ['error'] = '';
		$lang ["sta_getp"] = "getpass_index";
		$this->load->view ( 'public/v_getpass_index', $lang );
	}
	function getpassindex() {
		$lang ['error'] = '';
		$lang ["sta_getp"] = "getpassindex";
		$lang ["tjb_mail"] = $_POST ["tjb_mail"];
		$lang ["tjb_box"] = $_POST ["tjb_box"];
		$this->load->view ( 'public/v_getpass_index', $lang );
	}
	function getpassresetpwd() {
		parse_str($_SERVER['QUERY_STRING'],$_GET);
		$vstr = $_GET["vstr"];
		if($_GET["vstr"] == "" || $this->S($vstr) === ""){
			echo "worng";die;
		}
		$lang ['error'] = '';
		$lang ['vstr'] = $_GET["vstr"];
		$lang ["sta_getp"] = "getpassresetpwd";
		$this->load->view ( 'public/v_getpass_index', $lang );
	}
	function etpassresetpwd_2(){
		$map["usermail"] = $this->S($_POST['verifyvstr']);
		$data["password"] = md5($_POST["password"]);
		$this->m_tbk->update("user",$data,$map);
		$lang ["sta_getp"] = "success";
		$this->load->view ( 'public/v_getpass_index', $lang );
	}
	/**
	 * 缓存
	 */
	// 全局缓存设置和读取
	function S($name, $value = '', $expire = null, $type = '', $options = null) {
		static $_cache = array ();
		// 取得缓存对象实例
		$cache = new $this->cache;
		if ('' !== $value) {
			if (is_null ( $value )) {
				// 删除缓存
				$result = $cache->rm ( $name );
				if ($result)
					unset ( $_cache [$type . '_' . $name] );
				return $result;
			} else {
				// 缓存数据
				$cache->set ( $name, $value, $expire );
				$_cache [$type . '_' . $name] = $value;
			}
			return;
		}
		if (isset ( $_cache [$type . '_' . $name] ))
			return $_cache [$type . '_' . $name];
		// 获取缓存数据
		$value = $cache->get ( $name );
		$_cache [$type . '_' . $name] = $value;
		return $value;
	}
}